package com.openlogic.common.logic.node.parse.node;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.text.StringEscapeUtils;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.google.common.collect.Maps;
import com.openlogic.common.logic.func.enums.FuncLibMethodsEnums;
import com.openlogic.common.logic.node.enums.OpTypeEnums;
import com.openlogic.common.logic.utils.NumericRegxUtils;

/**
* @ClassName: BaseSubNodeParseHandler
* @Description: 子节点解析策略 策略模式 NodeInfo节点里value子节点解析处理器 策略接口
* @author weiyongpeng
* @date 2024年7月14日 下午2:46:08
 */
public abstract class BaseSubNodeParseHandler {
	
	/**
	* 描述：模板方法：默认子节点定义解析
	* @Title: getEveryElementByNode
	* @param tmpObject
	* @param resultList
	* @param areMap
	* @param lineObject
	* @return
	* @author weiyongpeng
	* @date  2024年7月14日 下午2:46:03
	 */
	public List<List<?>> getElementByNode(JSONObject tmpObject, List<List<?>> resultList, Map<String,String> areMap,JSONObject lineObject){
		List<Object> list=new ArrayList<Object>();
		list.add(tmpObject.get("id").toString()); // 获取id
		list.add(tmpObject.get("name") == null ? "" : tmpObject.get("name").toString()); // 获取name
		list.add(tmpObject.get("type").toString()); // 获取belongType 所属域的类型
		list.add(tmpObject.get("data") == null ? "" : getDataInfo(tmpObject.get("data").toString()));
		list.add("");
		list.add(tmpObject.get("type").toString()); // 获取type
		list.add(false);
		list.add(getlistMap(lineObject,tmpObject.get("id").toString()));//添加该节点对应向下线路的id
		list.add(tmpObject.get("dataBind") == null ? Maps.newHashMap() : getDataBind(tmpObject.get("dataBind").toString())); // 获取节点绑定变量的数据
		resultList.add(list);
		return resultList;
	}
	
	protected Map<String, Object> getDataBind(String dataBindStr) {
		Map<String, Object> dataBindMap = new HashMap<>();
		JSONArray parseArray = JSON.parseArray(dataBindStr);
		for (Object object : parseArray) {
			JSONObject jsonObject = JSONObject.parseObject(object.toString());
			// key:modelIdentify value:name
			dataBindMap.put(jsonObject.getString("modelIdentify"), jsonObject.getString("name"));
		}
		return dataBindMap;
	}

	/**
	* 描述：拆分节点中的data信息：分为if、success、failed 
	* @Title: getDataInfo
	* @param dataStr
	* @return
	* @author weiyongpeng
	* @date  2024年7月14日 下午2:59:52
	 */
	protected Map<String, String> getDataInfo(String dataStr) {
		Map<String, String> map = new HashMap<String, String>();

		JSONObject tmpObject = JSON.parseObject(dataStr);
		String ifValue = tmpObject.get("if") == null ? "" : tmpObject.get("if").toString();
		ifValue = StringEscapeUtils.unescapeXml(ifValue);
		map.put("if", concatStrNew(ifValue, 1));

		String successValue = tmpObject.get("success") == null ? "" : tmpObject.get("success").toString();
		successValue = StringEscapeUtils.unescapeXml(successValue);
		map.put("success", concatStrNew(successValue, 2));

		String failedValue = tmpObject.get("failed") == null ? "" : tmpObject.get("failed").toString();
		failedValue = StringEscapeUtils.unescapeXml(failedValue);
		map.put("failed", concatStrNew(failedValue, 3));

		return map;
	}
	
	/**
	* 描述：对if、success、failed各个环节的数据进行拼接
	* @Title: concatStrNew
	* @param str if、success、failed对应的字符串
	* @param type
	* @return
	* @author weiyongpeng
	* @date  2024年7月14日 下午3:02:53
	 */
	private String concatStrNew(String str, int type) {
		String value = "";
		JSONArray tmpObject = JSON.parseArray(str);
		if (null == tmpObject)
			return "";
		for (int i = 0; i < tmpObject.size(); i++) {
			JSONArray tmpArray = tmpObject.getJSONArray(i);
			for (int m = 0; m < tmpArray.size(); m++) {
				JSONObject tmpObj = (JSONObject) tmpArray.get(m);
				String tmp = "";
				if (tmpObj.get("value") == null || "undefined".equals(tmpObj.get("value").toString())
						|| "".equals(tmpObj.get("value").toString())) {
					tmp = "";
				} else if(tmpObj.get("type") != null && tmpObj.get("type").toString().equals("func")) { // 判断是否引用外部方法，如果引用，需要将方法进行拆分重组，20240725-addBy-weiyongpeng-适用于新绩效
					// ^com.dhcc.funclib.Arith.add^#(#PT_VALUE#,#FS_VALUE#)
					// ^com.dhcc.funclib.Arith.add^#(#^com.dhcc.funclib.Arith.add^#(#PT_VALUE#,#FS_VALUE#)#,#FS_VALUE#)
					// ^com.dhcc.funclib.Arith.add^#(#^com.dhcc.funclib.Arith.add^#(#PT_VALUE#,#FS_VALUE#)#,#FS_VALUE#) + 1
					String orgStr = tmpObj.get("value").toString();// 原始函数字符串
					String orgStrNew = funcParseNew(orgStr);
					tmp = orgStrNew;
				} else {
					if (tmpObj.get("class") == null) { // 判断是否引用外部方法，如果引用则需要将方法路径拼接到方法名前
						if (tmpObj.get("type") == null || !tmpObj.get("type").equals("sql")) {
							tmp = tmpObj.get("value").toString().replace(" ", "");
						} else {
							tmp = "@" + tmpObj.get("value").toString().replace(" ", "") + "@";
						}
					} else {
						tmp = "^" + tmpObj.get("class").toString() + "." + tmpObj.get("value").toString() + "^";
					}

				}
				value += tmp;
				value += "#";
			}
			value += "&@";
		}
		if (type == 1) {// if部分
			if (value != "") {
				String[] iflist = value.split("&@");
				String ifstr = "";
				for (int k = 0, iflength = iflist.length; k < iflength; k++) {
					if (iflist[k].equals("1#")) {
						ifstr += "&&";
					} else if (iflist[k].equals("2#")) {
						ifstr += "||";
					} else {
						if (iflist[k].contains("&&") || iflist[k].contains("AND")) {
							String[] iflistAnd = iflist[k].split("AND");
							for (int m = 0, iflistAndLength = iflistAnd.length; m < iflistAndLength; m++) {
								String[] ifandlist = iflistAnd[m].split("&&");
								for (int n = 0, iflength1 = ifandlist.length; n < iflength1; n++) {
									String[] iflist1 = ifandlist[n].split("#");
									Boolean isOp = false;
									for (int h = 0, iflength2 = iflist1.length; h < iflength2; h++) {
										if (iflist1[0].equals("")) {
											if (h != 0) {
												if (h != 2) {
													if (NumericRegxUtils.isNumeric(iflist1[h]) && !isOp) {// 数字不加引号
														ifstr += iflist1[h];
													} else {
														if (isOp) {
															ifstr += "'" + iflist1[h] + "')";
														}else if(iflist1[h].contains("@")){
															ifstr += iflist1[h];
														}else {
															//ifstr += "'" + iflist1[h] + "'";
															ifstr += iflist1[h];
														}
													}
												} else {// 符号不加引号
													if (iflist1[h].contains(OpTypeEnums.CONTAINS.getCode())) {
														isOp = true;
														ifstr += OpTypeEnums.CONTAINS.getOperatePrefix();
													}else if(iflist1[h].contains(OpTypeEnums.NOT_CONTAINS.getCode())){
														isOp = true;
														ifstr += OpTypeEnums.NOT_CONTAINS.getOperatePrefix();
													}else {
														ifstr += iflist1[h];
													}
												}
											}
										} else {
											if (h != 1) {
												if (NumericRegxUtils.isNumeric(iflist1[h]) && !isOp) {// 数字不加引号
													ifstr += iflist1[h];
												} else {
													if (isOp) {
														ifstr += "'" + iflist1[h] + "')";
													}else if(iflist1[h].contains("@")){
														ifstr += iflist1[h];
													}else {
														//ifstr += "'" + iflist1[h] + "'";
														ifstr += iflist1[h];
													}
												}
											} else {// 符号不加引号
												if (iflist1[h].contains(OpTypeEnums.CONTAINS.getCode())) {
													isOp = true;
													ifstr += OpTypeEnums.CONTAINS.getOperatePrefix();
												}else if(iflist1[h].contains(OpTypeEnums.NOT_CONTAINS.getCode())){
													isOp = true;
													ifstr += OpTypeEnums.NOT_CONTAINS.getOperatePrefix();
												}else {
													ifstr += iflist1[h];
												}
											}
										}
									}
									if (n < ifandlist.length - 1) {
										ifstr += "&&";
									}
								}
								if (m < iflistAnd.length - 1) {
									ifstr += "AND";
								}
							}
						} else {
							String[] iflist1 = iflist[k].split("#");
							boolean isSql = false;
							boolean isOp = false;
							for (int h = 0, iflength1 = iflist1.length; h < iflength1; h++) {
								if (h != 1) {
									if (NumericRegxUtils.isNumeric(iflist1[h])) {// 数字不加引号
										if (isSql && isOp) {
											ifstr += "'" + iflist1[h] + "')"; // sql参数除外
										}else {
											if (isOp) {
												ifstr += "'" + iflist1[h] + "')";
											}else {
												ifstr += iflist1[h];
											}
										}
									} else {
										if (iflist1[h].contains("@")) { // sql参数
											isSql = true;
											if (isSql && isOp) {
												ifstr += iflist1[h] + ")"; 
											}else {
												ifstr += iflist1[h];
											}
										}else {
											if (isOp) {
												ifstr += "'" + iflist1[h] + "')"; 
											}else {
												//ifstr += "'" + iflist1[h] + "'"; // 普通非数字加引号
												ifstr += iflist1[h];
											}
										}
									}
								} else {
									if (iflist1[h].equals(OpTypeEnums.CONTAINS.getCode())) {
										isOp = true;
										ifstr += OpTypeEnums.CONTAINS.getOperatePrefix(); // sql参数特殊集合操作符
									}else if(iflist1[h].contains(OpTypeEnums.NOT_CONTAINS.getCode())){
										isOp = true;
										ifstr += OpTypeEnums.NOT_CONTAINS.getOperatePrefix();
									}else {
										ifstr +=  iflist1[h]; // 符号不加引号
									}
								}
							}
						}
					}
				}
				value = ifstr;
			}
		} else if (type == 2) {// success部分
			if (value != "") {
				String[] iflist = value.split("&@");
				String ifstr = "";
				for (int k = 0, iflength = iflist.length; k < iflength; k++) {
					String[] iflist1 = iflist[k].split("#");
					for (int h = 0, iflength1 = iflist1.length; h < iflength1; h++) {
						if (h == 0) {
							ifstr += iflist1[h].replace("@", "");
						}else {
							ifstr += iflist1[h];
						}
					}
					ifstr += "&@";
				}
				value = ifstr;
			}
		} else {// failed部分
			if (value != "") {
				String[] iflist = value.split("&@");
				String ifstr = "";
				for (int k = 0, iflength = iflist.length; k < iflength; k++) {
					String[] iflist1 = iflist[k].split("#");
					for (int h = 0, iflength1 = iflist1.length; h < iflength1; h++) {
						if (h == 0) {
							ifstr += iflist1[h].replace("@", "");
						}else {
							ifstr += iflist1[h];
						}
					}
					ifstr += "&@";
				}
				value = ifstr;
			}
		}
		return value;
	}

	/**
	* 描述：解析函数库
	* @Title: funcParseNew
	* @param orgStr
	* @author weiyongpeng
	* @date  2024年7月25日 下午3:57:07
	 */
	private static String funcParseNew(String orgStr) {
		orgStr = orgStr.replaceAll(" ", "");
		if(orgStr.contains(FuncLibMethodsEnums.CUS_MATH.getCode())) {
			if(orgStr.contains(FuncLibMethodsEnums.CUS_MATH_ADD.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.CUS_MATH_ADD.getCode(), "^" + FuncLibMethodsEnums.CUS_MATH_ADD.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.CUS_MATH_SUB.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.CUS_MATH_SUB.getCode(), "^" + FuncLibMethodsEnums.CUS_MATH_SUB.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.CUS_MATH_DIV.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.CUS_MATH_DIV.getCode(), "^" + FuncLibMethodsEnums.CUS_MATH_DIV.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.CUS_MATH_DIVBYSCALE.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.CUS_MATH_DIVBYSCALE.getCode(), "^" + FuncLibMethodsEnums.CUS_MATH_DIVBYSCALE.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.CUS_MATH_MOD.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.CUS_MATH_MOD.getCode(), "^" + FuncLibMethodsEnums.CUS_MATH_MOD.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.CUS_MATH_MUL.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.CUS_MATH_MUL.getCode(), "^" + FuncLibMethodsEnums.CUS_MATH_MUL.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.CUS_MATH_ROUND.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.CUS_MATH_ROUND.getCode(), "^" + FuncLibMethodsEnums.CUS_MATH_ROUND.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.CUS_MATH_ROUNDUP.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.CUS_MATH_ROUNDUP.getCode(), "^" + FuncLibMethodsEnums.CUS_MATH_ROUNDUP.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.CUS_MATH_ROUNDDOWN.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.CUS_MATH_ROUNDDOWN.getCode(), "^" + FuncLibMethodsEnums.CUS_MATH_ROUNDDOWN.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.CUS_MATH_AVERAGE.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.CUS_MATH_AVERAGE.getCode(), "^" + FuncLibMethodsEnums.CUS_MATH_AVERAGE.getCode() + "^");
			}
		}else if(orgStr.contains(FuncLibMethodsEnums.AVIATOR_MATH.getCode())) {
			if(orgStr.contains(FuncLibMethodsEnums.AVIATOR_MATH_ABS.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.AVIATOR_MATH_ABS.getCode(), "^" + FuncLibMethodsEnums.AVIATOR_MATH_ABS.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.AVIATOR_MATH_ROUND.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.AVIATOR_MATH_ROUND.getCode(), "^" + FuncLibMethodsEnums.AVIATOR_MATH_ROUND.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.AVIATOR_MATH_POW.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.AVIATOR_MATH_POW.getCode(), "^" + FuncLibMethodsEnums.AVIATOR_MATH_POW.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.AVIATOR_MATH_SQRT.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.AVIATOR_MATH_SQRT.getCode(), "^" + FuncLibMethodsEnums.AVIATOR_MATH_SQRT.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.AVIATOR_MATH_LOG.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.AVIATOR_MATH_LOG.getCode(), "^" + FuncLibMethodsEnums.AVIATOR_MATH_LOG.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.AVIATOR_MATH_LOG10.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.AVIATOR_MATH_LOG10.getCode(), "^" + FuncLibMethodsEnums.AVIATOR_MATH_LOG10.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.AVIATOR_MATH_FLOOR.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.AVIATOR_MATH_FLOOR.getCode(), "^" + FuncLibMethodsEnums.AVIATOR_MATH_FLOOR.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.AVIATOR_MATH_SIN.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.AVIATOR_MATH_SIN.getCode(), "^" + FuncLibMethodsEnums.AVIATOR_MATH_SIN.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.AVIATOR_MATH_CEIL.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.AVIATOR_MATH_CEIL.getCode(), "^" + FuncLibMethodsEnums.AVIATOR_MATH_CEIL.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.AVIATOR_MATH_ASIN.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.AVIATOR_MATH_ASIN.getCode(), "^" + FuncLibMethodsEnums.AVIATOR_MATH_ASIN.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.AVIATOR_MATH_FLOOR.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.AVIATOR_MATH_FLOOR.getCode(), "^" + FuncLibMethodsEnums.AVIATOR_MATH_FLOOR.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.AVIATOR_MATH_COS.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.AVIATOR_MATH_COS.getCode(), "^" + FuncLibMethodsEnums.AVIATOR_MATH_COS.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.AVIATOR_MATH_TAN.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.AVIATOR_MATH_TAN.getCode(), "^" + FuncLibMethodsEnums.AVIATOR_MATH_TAN.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.AVIATOR_MATH_ATAN.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.AVIATOR_MATH_ATAN.getCode(), "^" + FuncLibMethodsEnums.AVIATOR_MATH_ATAN.getCode() + "^");
			}
		}else if(orgStr.contains(FuncLibMethodsEnums.CUS_STATIS.getCode())) {
			if(orgStr.contains(FuncLibMethodsEnums.CUS_STATIS_VARIANCE.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.CUS_STATIS_VARIANCE.getCode(), "^" + FuncLibMethodsEnums.CUS_STATIS_VARIANCE.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.CUS_STATIS_POPULATION_VARIANCE.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.CUS_STATIS_POPULATION_VARIANCE.getCode(), "^" + FuncLibMethodsEnums.CUS_STATIS_POPULATION_VARIANCE.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.CUS_STATIS_STANDARD_DIVIATION.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.CUS_STATIS_STANDARD_DIVIATION.getCode(), "^" + FuncLibMethodsEnums.CUS_STATIS_STANDARD_DIVIATION.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.CUS_STATIS_MEDIAN.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.CUS_STATIS_MEDIAN.getCode(), "^" + FuncLibMethodsEnums.CUS_STATIS_MEDIAN.getCode() + "^");
			}
		}else if(orgStr.contains(FuncLibMethodsEnums.CUS_STRING.getCode())) {
			if(orgStr.contains(FuncLibMethodsEnums.CUS_STRING_CONCAT.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.CUS_STRING_CONCAT.getCode(), "^" + FuncLibMethodsEnums.CUS_STRING_CONCAT.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.CUS_STRING_CONCATENAT.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.CUS_STRING_CONCATENAT.getCode(), "^" + FuncLibMethodsEnums.CUS_STRING_CONCATENAT.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.CUS_STRING_LEFTSTR.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.CUS_STRING_LEFTSTR.getCode(), "^" + FuncLibMethodsEnums.CUS_STRING_LEFTSTR.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.CUS_STRING_RIGHTSTR.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.CUS_STRING_RIGHTSTR.getCode(), "^" + FuncLibMethodsEnums.CUS_STRING_RIGHTSTR.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.CUS_STRING_LEN.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.CUS_STRING_LEN.getCode(), "^" + FuncLibMethodsEnums.CUS_STRING_LEN.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.CUS_STRING_LOWER.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.CUS_STRING_LOWER.getCode(), "^" + FuncLibMethodsEnums.CUS_STRING_LOWER.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.CUS_STRING_UPPER.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.CUS_STRING_UPPER.getCode(), "^" + FuncLibMethodsEnums.CUS_STRING_UPPER.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.CUS_STRING_REPLACE.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.CUS_STRING_REPLACE.getCode(), "^" + FuncLibMethodsEnums.CUS_STRING_REPLACE.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.CUS_STRING_REPLACEPLUS.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.CUS_STRING_REPLACEPLUS.getCode(), "^" + FuncLibMethodsEnums.CUS_STRING_REPLACEPLUS.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.CUS_STRING_REVERSE.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.CUS_STRING_REVERSE.getCode(), "^" + FuncLibMethodsEnums.CUS_STRING_REVERSE.getCode() + "^");
			}
		}else if(orgStr.contains(FuncLibMethodsEnums.CUS_COLLECTION.getCode())) {
			if(orgStr.contains(FuncLibMethodsEnums.CUS_COLLECTION_CONTAINS.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.CUS_COLLECTION_CONTAINS.getCode(), "^" + FuncLibMethodsEnums.CUS_COLLECTION_CONTAINS.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.CUS_COLLECTION_NOTCONTAINS.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.CUS_COLLECTION_NOTCONTAINS.getCode(), "^" + FuncLibMethodsEnums.CUS_COLLECTION_ADD.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.CUS_COLLECTION_ADD.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.CUS_COLLECTION_ADD.getCode(), "^" + FuncLibMethodsEnums.CUS_COLLECTION_ADD.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.CUS_COLLECTION_CONCAT.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.CUS_COLLECTION_CONCAT.getCode(), "^" + FuncLibMethodsEnums.CUS_COLLECTION_CONCAT.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.CUS_COLLECTION_DISTINCT.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.CUS_COLLECTION_DISTINCT.getCode(), "^" + FuncLibMethodsEnums.CUS_COLLECTION_DISTINCT.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.CUS_COLLECTION_REMOVE.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.CUS_COLLECTION_REMOVE.getCode(), "^" + FuncLibMethodsEnums.CUS_COLLECTION_REMOVE.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.CUS_COLLECTION_TO_LIST.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.CUS_COLLECTION_TO_LIST.getCode(), "^" + FuncLibMethodsEnums.CUS_COLLECTION_TO_LIST.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.CUS_COLLECTION_TO_SET.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.CUS_COLLECTION_TO_SET.getCode(), "^" + FuncLibMethodsEnums.CUS_COLLECTION_TO_SET.getCode() + "^");
			}else if(orgStr.contains(FuncLibMethodsEnums.CUS_COLLECTION_TO_MAP.getCode())) {
				orgStr=orgStr.replaceAll(FuncLibMethodsEnums.CUS_COLLECTION_TO_MAP.getCode(), "^" + FuncLibMethodsEnums.CUS_COLLECTION_TO_MAP.getCode() + "^");
			}
		}
		orgStr = orgStr.replaceAll("\\(", "#(#")
				.replaceAll("\\)", "#)")
				.replaceAll("\\+", "#+#")
				.replaceAll("\\-", "#-#")
				.replaceAll("\\*", "#*#")
				.replaceAll("\\/", "#/#");
		return orgStr;
	}
	
	/**
	* 描述：获取该节点对应后续连线
	* @Title: getlistMap
	* @param lineObject 线数据
	* @param nodeId 当前节点id
	* @return
	* @author weiyongpeng
	* @date  2024年7月14日 下午3:05:42
	 */
	protected List<String> getlistMap(JSONObject lineObject, String nodeId) {
		List<String> lines = new ArrayList<String>();
		for (Map.Entry<String, Object> entry : lineObject.entrySet()) {
			JSONObject lineobjectnew = JSON.parseObject(entry.getValue().toString());
			if (lineobjectnew.get("from").equals(nodeId)) {
				lines.add(entry.getKey().toString());
			}
		}
		return lines;
	}
}
